package chapter19.homework2;

public class Student implements Comparable<Student>{//实现Comparable
    private String name;//姓名
    private int age;//年龄

    public Student(String name, int age){
        super();
        this.name = name;
        this.age = age;
    }

    public void setName(String name){
        this.name = name;
    }
    public String getName(){
        return name;
    }
    public void setAge(int age){
        this.age = age;
    }
    public int getAge(){
        return age;
    }

    public int compareTo(Student stu){
        if(this.age > stu.age){
            return -1;
        }else if(this.age < stu.age){
            return 1;
        }
        return 0;
    }
}
